import request from "@/api/request.ts";

// 获取字典类型列表
export const getDictTypeTree = (): Promise<apiServerResponse> => {
  return request({
    url: "/sysDictType/dictTypeList",
    method: "GET",
  });
};

// 新增字典类型
export const addSysDictType = (
  data: SysDictDataEntity
): Promise<apiServerResponse> => {
  return request({
    url: "/sysDictType/add",
    method: "POST",
    data,
  });
};

// 修改字典类型
export const updateSysDictType = (
  data: SysDictDataEntity
): Promise<apiServerResponse> => {
  return request({
    url: "/sysDictType/update",
    method: "PUT",
    data,
  });
};

// 删除字典类型
export const deleteSysDictTypeById = (
  id: String
): Promise<apiServerResponse> => {
  return request({
    url: `/sysDictType/deleteById/${id}`,
    method: "DELETE",
  });
};

// 获取字典数据分页数据
export const getDictDataByPage = (
  params: SysDictDataEntityRequestParams
): Promise<apiServerResponse> => {
  return request({
    url: "/sysDictData/dictDataByPage",
    method: "GET",
    params,
  });
};

// 新增字典数据
export const addDictData = (
  data: SysDictDataEntity
): Promise<apiServerResponse> => {
  return request({
    url: "/sysDictData/add",
    method: "POST",
    data,
  });
};

// 修改字典数据
export const updateDictData = (
  data: SysDictDataEntity
): Promise<apiServerResponse> => {
  return request({
    url: "/sysDictData/update",
    method: "PUT",
    data,
  });
};

// 删除字典数据
export const deleteDictDataById = (id: String): Promise<apiServerResponse> => {
  return request({
    url: `/sysDictData/deleteById/${id}`,
    method: "DELETE",
  });
};

// 批量删除字典数据
export const deleteBatchDictData = (
  data: Array<String>
): Promise<apiServerResponse> => {
  return request({
    url: `/sysDictData/deleteBatchByIds`,
    method: "DELETE",
    data,
  });
};

// 初始化字典数据数据
export const getDictInfo = (
  data: Array<String>
): Promise<apiServerResponse> => {
  return request({
    url: "/sysDictData/getDictInfo",
    method: "POST",
    data,
  });
};
// 刷新字典缓存数据数据
export const refreshDictCache = (): Promise<apiServerResponse> => {
  return request({
    url: "/sysDictData/refreshDictCache",
    method: "GET",
  });
};
